package thread;

public class CeaseThread {
    public static void main(String[] args) {
        T1 t1 = new T1();
        Thread thread = new Thread(t1);
        thread.start();
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        t1.run = false;
    }
}
class T1 implements Runnable{
    boolean run = true;
    @Override
    public void run() {
        int i=0;
        while (run){
            System.out.println(Thread.currentThread().getName() + "->" + i);
            i++;
        }
    }
}